<?php $this->Html->addCrumb('Newsletters', '/member/newsletters');
$this->Html->scriptStart(array('inline' => false));
echo '
      $(function(){
         $(".deleteLink").click(function(event){
          var $link = $(this);
          $.TWS_Overlay("confirm", {title : "Delete confirmation", message : "Are you sure you want to delete this record?", buttons : {ok :{onclick : function () { $.TWS_Overlay("hide"); location.href=$link.attr("href");}}}});
          event.preventDefault();
        });
        $(".displayContent").cluetip({splitTitle: "|", cluetipClass: "tws", dropShadow : false, positionBy : "mouse", cursor : "default"});
      });
       ';
$this->Html->scriptEnd();
?>

<h1>Newsletters</h1>
<?php echo $this->Session->flash();?>
<?php echo '<div id="actionLink">'.$this->Html->link('Add Newsletter', array('controller' => 'newsletters', 'action' => 'add', 'member'=>true)).'</div>'; ?>
<? if (empty($newsletters)) { echo '<p>No Newsletters are currently available.</p>'; }
 else {
  ?>
   <table class="results" >
    <thead>
      <tr>
        <th width="65%"><?php echo $this->Paginator->sort('title','Title')?></th>
        <th width="15%">Download</th>
        <th width="15%"><?php echo $this->Paginator->sort('newsletter_date','Date')?></th>
        <th width="15%">Actions</th>
      <tr>
   </thead>
   <tbody>
      <?php foreach ($newsletters as $newsletter) {
        $rec = $newsletter['Newsletter'];
        $editLink = $this->Html->link('Edit', array('controller' => 'newsletters', 'action' => 'edit', $rec['id']), array("title"=>"Edit this record"));
        $deleteLink = $this->Html->link('Delete', array('controller' => 'newsletters', 'action' => 'delete', $rec['id']), array("title"=>"Delete this record", "class"=>'deleteLink'));
        $title = $this->Html->displayPreview(($rec['title']));
        $newsletterDate = new DateTime($rec['newsletter_date']);
        echo '<tr>';
        echo '<td>'.$title.'</td>';
        echo '<td class="center"><a href="'.$this->Html->url('/'.$rec['file_path']).'" target="new">'.$this->Html->image('documentSmall.png', array("alt"=>"Document")).'</a></td>';
        echo '<td>'.$newsletterDate->format('m/d/Y').'</td>';
        echo "<td>$editLink&nbsp;&nbsp;$deleteLink</td>";
        echo '</tr>';
      }?>
   </tbody>
   </table>
  
<?php echo $this->element('pagination'); ?>

 <?php } ?>

